package cn.neusoft.runoobcc.doc;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import sun.text.resources.cldr.en.FormatData_en_JM;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 这个文档的作用
 * 1.初始换索引库
 * 2.文档的映射
 * 3，存储到es得数据封装
 */
@Document(indexName = "product" ,type = "_doc")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProductDoc {
    @Id  // 表示文档的id和字段的id值一致， /coure/_doc/id
    private long id;
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String name;
    @Field(type = FieldType.Keyword)
    private String typeId;
    @Field(type = FieldType.Keyword)
    private String typeName;
    @Field(type= FieldType.Integer)
    private Integer salesOlume;
    @Field(type = FieldType.Double)
    private BigDecimal originalPrice;
    @Field(type = FieldType.Double)
    private BigDecimal discountPrice;
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String describe;

}
